#ifndef __BSP_IRREMOTE_H
#define __BSP_IRREMOTE_H

#if __cplusplus
extern "C"
{
#endif

#if __cplusplus
}
#endif

#if __cplusplus
#include "bsp_Irq.h"
#include "bsp_Pwm.h"
#include "tool_Fifo.h"

class bsp_IrRemote : public bsp_Pwm, public tool_Fifo
{
private:
#define IRREMOTE_BUFFER_LEN 2048 // 红外发射数据缓存区长度
#define PRESCALER 4            // 分频系数
#define PERIOD 377               // 重装载值

    BSP_TIM_Handle_t *TIM;                      // 定时器句柄
    uint32_t Channel;                           // 通道
    QUEUE_DATA_T txBuffer[IRREMOTE_BUFFER_LEN]; // 发送缓冲区

public:
    bsp_IrRemote(BSP_TIM_Handle_t *htim, uint32_t channel) : bsp_Pwm(htim, channel, PRESCALER, PERIOD-1) /*72MHz/72/26≈38KHz载波*/, tool_Fifo(txBuffer, IRREMOTE_BUFFER_LEN)
    {
        TIM = htim;
        Channel = channel;
    }
    ~bsp_IrRemote()
    {
    }

    void sendCallBack(BSP_TIM_Handle_t *htim);
    void Send(QUEUE_DATA_T *buff, int size);
};

#if DEMO_IRREMOTE
extern bsp_IrRemote demoIrRemote;
#endif

#endif

#endif
